package com.github.pig.nideshop.controller.user;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.github.pig.common.util.ZyResult;
import com.github.pig.nideshop.entity.NideshopAd;
import com.github.pig.nideshop.entity.NideshopAdPosition;
import com.github.pig.nideshop.service.INideshopAdPositionService;
import com.github.pig.nideshop.service.INideshopAdService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author J神
 * @since 2018-06-11
 */
@RestController
@RequestMapping("/adPositions")
@Api(value = "广告位置")
public class NideshopAdPositionController {
        @Autowired
        private INideshopAdPositionService nideshopAdPositionService;
        @Autowired
        private INideshopAdService nideshopAdService;

        /**
         * 获取广告位置列表
         * @param nideshopAdPosition
         * @param page
         * @return
         */
        @GetMapping
        public ZyResult adPositions(NideshopAdPosition nideshopAdPosition, Page page){
            return ZyResult.ok(nideshopAdPositionService.selectPage(page,new EntityWrapper<>(nideshopAdPosition)));
        }

        /**
         * 获取广告位置详情
         * @param adPositionId
         * @param nideshopAd
         * @return
         */
        @GetMapping("/{adPositionId}")
        public ZyResult adPosition(@PathVariable(value = "adPositionId") String adPositionId, NideshopAd nideshopAd){
            return ZyResult.ok(nideshopAdService.selectList(new EntityWrapper(nideshopAd)));
        }
}

